package com.example.hehecat.yuejian1.mvp.model;

import com.example.hehecat.yuejian1.http.RetrofitHttp;
import com.example.hehecat.yuejian1.mvp.contract.IssuePictureContract;
import com.example.hehecat.yuejian1.mvp.model.bean.SuccessBean;

import java.util.HashMap;
import java.util.Map;

import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class IssuePictureModel implements IssuePictureContract.Model {
    @Override
    public void issuePicture(String picturename, String intro, MultipartBody.Part picture1, int user_id, Subscriber<SuccessBean> subscriber) {

        Map m1 = new HashMap();
        m1.put("intro",intro);
        Map<String, String> m2 = new HashMap<>();
        m2.put("picturename",picturename);
        Integer userid = user_id;
        Map<String, Integer> m3 = new HashMap<>();
        m3.put("userid",userid);

        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).doFeedback(m1,m2,m3,picture1)
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

}
